/**
 * input： 输入,回显需要传value字段,失焦提交accept事件,内容 @returns
 * @params propItem
 *
propItem = {
  label: {
      type: String,
      require: true,
      introduction: 'field 的 label',
    },
    code: {
      type: String,
      require: true,
      introduction: '前后端统一的字段名',
    },
    placeholder: {
      type: String,
      require: true,
      introduction: 'field 的 placeholder',
    },
    value: {
      type: String,
      require: false,
      introduction: 'field 的 value',
    },
    unnecessary: {
      type: Boolean,
      require: false,
      introduction: 'true 为非必传,不在此处使用,提交前验证',
    },
    maxlength: {
      type: String || Number,
      require: false,
      introduction: '限制字符数,设值后会展示字符限制',
    },
    rules:{
      type:Array,
      require: false,
      introduction: '校验',
    }
}
 * @returns object
 {
   value: 'outPutName',
   code: 'patientName',
 }
 */
export default {
  props: {
    propItem: Object,
  },
  data() {
    return {
      innerValue: '',
      ...this.propItem,
    };
  },
  mounted() {
    this.innerValue = this.value;
  },
  methods: {
    transmit() {
      this.$emit('accept', { value: this.innerValue, code: this.code });
    },
  },
  render() {
    return (
      <van-field
        v-model={this.innerValue}
        label={this.label}
        placeholder={this.placeholder}
        maxlength={this.maxlength}
        show-word-limit={!!this.maxlength}
        onBlur={this.transmit}
        rules={this.rules}
      />
    );
  },
};
